package org.zju.demo.shoppingdemo.controller;

import com.google.gson.Gson;

import org.zju.demo.shoppingdemo.activity.BaseActivityInterface;
import org.zju.demo.shoppingdemo.model.Request.BaseModel;
import org.zju.demo.shoppingdemo.model.Request.BuyProductsModel;
import org.zju.demo.shoppingdemo.model.Request.GetDeliveryStatusModel;
import org.zju.demo.shoppingdemo.model.Request.GetGoodModel;
import org.zju.demo.shoppingdemo.model.Request.GetProductModel;
import org.zju.demo.shoppingdemo.model.Request.QueryAllOrdersModel;
import org.zju.demo.shoppingdemo.model.Request.UpdateOrderModel;
import org.zju.demo.shoppingdemo.model.response.BaseResponse;
import org.zju.demo.shoppingdemo.model.response.ResponseCategoryJson;
import org.zju.demo.shoppingdemo.model.response.ResponseDeliveryJson;
import org.zju.demo.shoppingdemo.model.response.ResponseHotJson;
import org.zju.demo.shoppingdemo.model.response.ResponseOrderJson;
import org.zju.demo.shoppingdemo.model.response.ResponseProductDetailJson;
import org.zju.demo.shoppingdemo.model.response.ResponseQueryOrderJson;
import org.zju.demo.shoppingdemo.task.HttpAsyncTask;
import org.zju.demo.shoppingdemo.utils.Constant;

/**
 * Created by ZJDX on 2015/9/9.
 */
public class ShoppingController {
    private ShoppingController() {
    }
    public static void doQueryHot(BaseActivityInterface activityInterface, BaseModel model) {
        Gson gson = new Gson();
        Object[] params = {Constant.QUERYHOT_URL, Constant.POST_METHOD, gson.toJson(model)};
        HttpAsyncTask task = new HttpAsyncTask(activityInterface, ResponseHotJson.class);
        task.execute(params);
    }
    public static void doQueryCategory(BaseActivityInterface activityInterface, GetGoodModel model) {
        Gson gson = new Gson();
        Object[] params = {Constant.GETGOODS_URL, Constant.POST_METHOD, gson.toJson(model)};
        HttpAsyncTask task = new HttpAsyncTask(activityInterface, ResponseCategoryJson.class);
        task.execute(params);
    }
    public static void doQueryProduct(BaseActivityInterface activityInterface, GetProductModel model) {
        Gson gson = new Gson();
        Object[] params = {Constant.GETPRODUCT_URL, Constant.POST_METHOD, gson.toJson(model)};
        HttpAsyncTask task = new HttpAsyncTask(activityInterface, ResponseProductDetailJson.class);
        task.execute(params);
    }
    public static void doBuyProduct(BaseActivityInterface activityInterface, BuyProductsModel model) {
        Gson gson = new Gson();
        Object[] params = {Constant.BUYPRODUCT_URL, Constant.POST_METHOD, gson.toJson(model)};
        HttpAsyncTask task = new HttpAsyncTask(activityInterface, ResponseOrderJson.class);
        task.execute(params);
    }
    public static void doQueryAllOrders(BaseActivityInterface activityInterface, QueryAllOrdersModel model) {
        Gson gson = new Gson();
        Object[] params = {Constant.QUERYALLORDER_URL, Constant.POST_METHOD, gson.toJson(model)};
        HttpAsyncTask task = new HttpAsyncTask(activityInterface, ResponseQueryOrderJson.class);
        task.execute(params);
    }
    public static void doGetDeliveryStatus(BaseActivityInterface activityInterface, GetDeliveryStatusModel model) {
        Gson gson = new Gson();
        Object[] params = { Constant.QUERYDELIVERYSTATUS_URL, Constant.POST_METHOD, gson.toJson(model)};
        HttpAsyncTask task = new HttpAsyncTask(activityInterface, ResponseDeliveryJson.class);
        task.execute(params);
    }
    public static void doSetOrder(BaseActivityInterface activityInterface, UpdateOrderModel model) {
        Gson gson = new Gson();
        Object[] params = {Constant.UPDATEORDER_URL, Constant.POST_METHOD, gson.toJson(model)};
        HttpAsyncTask task = new HttpAsyncTask(activityInterface, BaseResponse.class);
        task.execute(params);
    }
}
